package top.lshaci.learning.springboot.mybatisplus.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.lshaci.learning.springboot.mybatisplus.entity.TableEntity;
import top.lshaci.learning.springboot.mybatisplus.mapper.TableMapper;
import top.lshaci.learning.springboot.mybatisplus.service.TableService;
import top.lshaci.learning.springboot.mybatisplus.util.TransactionUtil;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lshaci
 * @since 2022-06-23
 */
@Service
public class TableServiceImpl extends ServiceImpl<TableMapper, TableEntity> implements TableService {

    @Override
    public void insert(TableEntity entity) {
        baseMapper.insert(entity);

        TransactionUtil.afterCommit(() -> System.err.println("afterCommit1"));
        TransactionUtil.beforeCommit(() -> System.err.println("beforeCommit1"));

        TransactionUtil.afterCommit(() -> System.err.println("afterCommit2"));
        TransactionUtil.beforeCommit(() -> System.err.println("beforeCommit2"));

    }
}
